home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
Book Chapters
/
10 - Networking
/
NovelNetwar
/
NovelNetwar.h
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-12
|
5KB
|
238 lines
#include <stdio.h>
#include <string.h>
enum
{
BADWINDOW = 1, TRAPABSENT, GAMENOTPLAYING, NONETNAME, NOAPPLETALK, NOTEXTEDITREC, SERIALCONNECTCANCELLED
};
enum
{
NONE, APPLETALK, SERIAL, MACTCP
};
#define EQSTR 0
#define VERSION "Novel Netwar 1.0"
#define GAMEWIND 128
#define HELPWIND 129
#define HELPTEXT 128
#define HELPSTYL 128
#define INFODLOG 128
#define INPUTDLOG 129
#define TEXTDLOG 130
#define INFOCANCELDLOG 131
#define OKCANCELDLOG 132
#define ERRORDLOG 134
#define ATALKSTARTDLOG 133
#define SERIALDLOG 135
#define CHOOSEMETHODDLOG 136
#define RETURNKEY (char) 0x0d
#define MAXNUMPLAYERS 6
#define MAXNUMPHOTONS 3
#define MAXDDPPACKETSIZE 586
struct DDPDataPacket
{
UInt8 destNodeID;
UInt8 srcNodeID;
UInt8 ddpHeaderType;
UInt8 datagramLengthMSB;
UInt8 datagramLengthLSB;
UInt8 destSocketNumber;
UInt8 srcSocketNumber;
UInt8 ddpProtocolType;
char packetData[MAXDDPPACKETSIZE];
};
typedef struct DDPDataPacket DDPDataPacket;
struct GameData
{
short x;
short y;
short angleIndex;
short photonsX[MAXNUMPHOTONS];
short photonsY[MAXNUMPHOTONS];
short photonsTimeToLive[MAXNUMPHOTONS];
short playerStatus;
};
typedef struct GameData GameData;
extern char alive,IAmFrontApp,hasColourQD,hasAppleTalk;
extern Rect nullRect;
extern char errorMessage[256];
extern int connectionMethod;
// globals.c
void globalsInit(void);
void globalsStartup(void);
void globalsShutDown(void);
// helpbox.c
void DoHelpBox(int helpResWIND,int helpResTEXT,int helpResSTYL);
// windows.c
void windowsInit(void);
void windowsStartup(void);
void windowsShutDown(void);
void DoMouseDown(EventRecord *theEvent);
OSErr IsOurWindow(WindowPtr theWPtr);
void DoActivateDeactivate(WindowPtr whichWindow,char adFlag);
void DoCloseWindow(WindowPtr whichWindow);
void DoGrow(WindowPtr whichWindow,EventRecord *theEvent);
void DoZoom(WindowPtr whichWindow,int windowCode);
void DoDrag(WindowPtr whichWindow,EventRecord *theEvent);
void DoContent(WindowPtr whichWindow,EventRecord *theEvent);
void UpdateWindow(WindowPtr whichWindow);
void doUpdate(CWindowPtr window);
// dialogs.c
OSErr GetInput(char *thePrompt,char *theText);
OSErr YesNoDialog(char *thePrompt,int theDefault);
void FatalError(char *fatalString);
void ErrorAlert(char *p0);
OSErr ProcessDialogCmdKey(DialogPtr theDialog,EventRecord *theEvent,short *itemHit);
pascal Boolean MyFilter(DialogPtr theDialog,EventRecord *theEvent,short *itemHit);
void CenterWindow(WindowPtr wPtr);
pascal void HiliteDefaultButton(DialogPtr theDPtr,int whichItem);
// misc.c
OSErr BreakKey(void);
OSErr OptionKey(void);
OSErr CtrlKey(void);
OSErr ShiftKey(void);
OSErr CommandKey(void);
OSErr CapsLock(void);
void getGrayRgnRect(Rect *theRect);
void mystrncpy(register char *s1, register char *s2,register long n);
void mystrncat(register char *s1, register char *s2,register long n);
OSErr TrapAvailable(int theTrap);
// menus.c
void menusInit(void);
void menusStartup(void);
void menusShutDown(void);
OSErr DoCommand(long mResult);
void MarkReinforcementsMenu(void);
void DisableEditMenu(void);
void EnableEditMenu(void);
// helpbox.c
void helpInit(void);
void helpStartup(void);
void helpShutDown(void);
void DoHelpBox(int helpResWIND,int helpResTEXT,int helpResSTYL);
void helpCloseWindow(WindowPtr whichWindow);
void helpGrowWindow(WindowPtr whichWindow,EventRecord *theEvent);
void helpDragWindow(WindowPtr whichWindow,EventRecord *theEvent);
void helpActivateWindow(WindowPtr whichWindow,char adFlag);
OSErr helpIsWindow(WindowPtr theWPtr);
void helpUpdateWindow(WindowPtr theWPtr);
void helpDoContent(WindowPtr whichWindow,EventRecord *theEvent);
// main.c
void terminate(void);
void DoShutDown(void);
void mainDoIdle(void);
// myabout.c
void DoAboutBox(int doWait);
// cursors.c
void cursorsInit(void);
void cursorsStartup(void);
void cursorsShutDown(void);
void cursorsMaintainCursor(Point theMousePt);
void cursorReactToMouseClick(Point theMousePt);
// appleEvents.c
void appleEventsInit(void);
void appleEventsStartup(void);
void appleEventsShutDown(void);
void DoHighLevel(EventRecord *theEvent);
// gameplay.c
void gameplayInit(void);
void gameplayStartup(void);
void gameplayShutdown(void);
void gameplayDoContent(WindowPtr theWPtr,EventRecord *theEvent);
OSErr gameplayIsWindow(WindowPtr theWPtr);
void gameplayUpdateWindow(WindowPtr theWPtr);
void gameplayDragWindow(WindowPtr theWPtr,EventRecord *theEvent);
void gameplayActivateWindow(WindowPtr theWPtr,char adFlag);
void gameplayIdle(void);
void gameReceiveBroadcastData(Ptr theBroadcastData,long theBroadcastDataLength);
void gameplayHandleBroadcastCompletion(void);
// appletalking.c
void appletalkingInit(void);
void appletalkingStartup(void);
void appletalkingShutdown(void);
OSErr appleTalkingConnectToOpponents(void);
void appleTalkingSendData(Ptr theDataPtr,long theDataLength);
// serial.c
void serialInit(void);
void serialStartup(void);
void serialShutdown(void);
OSErr serialConnectToOpponents(void);
void serialSendData(Ptr theDataPtr,long theDataLength);